package main

import (
	"github.com/codegangsta/martini"
	"bytes"
	"h5utils"
	"io/ioutil"
    "net/http"
)
func main() {
	m := martini.Classic()


	m.Get("/", func(w http.ResponseWriter, req *http.Request) string {
		jsonStr := "{\"localInetAddress\":\"192.168.10.45\",\"hwModel\":\"MX6QV1\",\"networkType\":\"unknown\",\"deviceId\":\"450100363\",\"swVersion\":\"2.0.3-rc1.master.c75b8d6dfcd3b7b9a9cb96d17aedd3bc4b0f51a2\"}"
        // jsonStr := "{\"schoolName\":\"浙江第一实验小学\", \"class\":\"3年1班\", \"studentid\":\"oLqIzswoUIxq1xszxpbwj\"}"
        // jsonStr := "{\"studentId:oLqIzswoUIxq1xszxpbwjrPP1VX0\", \"actionType\":\"1\"}"
        // jsonStr := "{\"deviceID\":\"450100363\", \"taskId\":\"19\",\"status\":\"Testing\"}"
        body := bytes.NewBuffer([]byte(jsonStr))
        res, err := http.Post("http://pj.zlzkj.org:80/wsybc/device/registerDevice", "application/json;charset=utf-8", body)
        // res, err := http.Post("http://pj.zlzkj.org:80/wsybc/device/print", "application/json;charset=utf-8", body)
        h5utils.CheckErr(err)

        result, err := ioutil.ReadAll(res.Body)
        res.Body.Close()
        h5utils.CheckErr(err)
        
        return string(result)
	})

		m.Run()
}